<template>
    <div class="addDaily">
        <div class="addHead">
            <div class="title">
                <div class="breadcrumb">
                    <div class="breadcrumb__item breadcrumb__item--center" @click="back()">排班管理</div>
                    <div class="breadcrumb__item">/</div>
                    <div class="breadcrumb__item breadcrumb__item--center">
                        新增排班
                    </div>
                </div>
                <div class="breadcrumbBtn">
                    <div class="btn_ative" @click="handleConfirm()">
                        <img class="operation_btn" src="@/assets/images/images_new/save_icon.png" alt="">
                        <span>保存</span>
                    </div>
                    <div class="btn_ative" @click="back()">
                        <img class="operation_btn" src="@/assets/images/images_new/back_icon.png" alt="">
                        <span>返回</span>
                    </div>
                </div>
            </div>
            <div class="tips">*需先进行班组配置后才可进行排班管理，班组组长也需要配置排班信息才可正常接收任务</div>
            <div class="serchBar">
                <el-form class="form" :model="searchData" label-position="left">
                    <el-form-item label="班组名称">
                        <el-select v-model="searchData.name" class="m-2" placeholder="请选择班组名称" clearable>
                            <el-option label="电力班组" :value="0" />
                            <el-option label="锅炉班组" :value="1" />
                        </el-select>
                    </el-form-item>
                    <el-form-item label="排班时间">
                        <el-date-picker v-model="searchData.month" type="month" placeholder="排班时间" />
                    </el-form-item>
                </el-form>
            </div>

        </div>
        <div class="table">
            <div class="btn">
                <div class="btn_item">
                    <img class="btn_icon" src="@/assets/images/images_new/edit_icon.png" alt="">
                    <span>批量编辑</span>
                </div>
            </div>
            <div class="tableBg">
                <el-table ref="tableRef" :data="tableData.list" style="width: 100%;" stripe empty-text="暂无数据"
                    :max-height="table_height" :scrollbar-always-on="true">
                    <el-table-column property="date" label="日期/排班成员" />
                    <el-table-column v-for="item in tableData.list">
                        <template #header>
                            <span>{{ item.name }}</span>
                            <div class="btn_ative" title="编辑" @click="showAdd">
                                <img class="operation_btn" src="@/assets/images/images_new/edit_icon.png" alt="">
                            </div>
                        </template>
                        <template #default="scope">
                            <span>{{ scope.row.content }}</span>
                        </template>
                    </el-table-column>

                </el-table>
            </div>
        </div>
        <addDaily_dialog :dialogVisible="dialogVisible" @closeDialog="closeDialog"></addDaily_dialog>
    </div>
</template>

<script setup lang="ts">
import router from '@/routes';
import addDaily_dialog from "./addDaily_dialog.vue";

let searchData = reactive({
    name: '',
    month: ''
})

let tableData = reactive({
    list: [
        { name: "张三", date: '05-01', content: "1:30~2:00;早班（13:00~16:30）" },
        { name: "李四", date: '05-02', content: "" },
    ]
})
//保存
const handleConfirm = () => {

}

//返回
const back = () => {
    router.go(-1);
}

let table_height = ref(500)

let dialogVisible = ref(false);//是否打开弹窗

//关闭弹窗
const closeDialog = ()=>{
    dialogVisible.value = false;
}

//打开新增编辑弹窗
const showAdd = ()=>{
    dialogVisible.value = true;
}

</script>

<style lang="scss" scoped>
.addDaily {
    background-color: #e5e5e5;
    height: 100%;
    min-height: 0;
    padding: 0 15px;
    display: flex;
    flex-direction: column;

    .addHead {
        background: rgb(255, 255, 255);
        border-radius: 0px 0px 8px 8px;
        padding-left: 30px;
        height: 168px;

        .title {
            display: flex;
            justify-content: space-between;
            align-items: center;
            // margin-bottom: 20px;
            height: 85px;


            .breadcrumb {
                width: 320px;
                height: 38px;
                display: flex;
                align-items: center;
                justify-content: space-between;
                padding: 0 10px;
                border: 1px solid rgba(0, 0, 0, 0.05);
                font-size: 16px;
                font-weight: 400;

                .breadcrumb__item {
                    display: flex;
                    align-items: center;

                    &:first-child {
                        cursor: pointer;
                        color: rgb(151, 151, 151);
                    }
                }

                .breadcrumb__item--center {
                    flex: 1;
                    justify-content: center;
                }
            }

            .breadcrumbBtn {
                margin-right: 42.5px;
                display: flex;

                .btn_ative {
                    width: auto;
                    height: 35px;
                    line-height: 35px;
                    cursor: pointer;
                    display: inline-block;
                    margin-right: 18px;
                    display: flex;
                    align-items: center;
                    color: #353535;
                    font-size: 14px;
                    padding: 0 8px;

                    &:last-child {
                        margin-right: 0;
                    }

                    &:hover {
                        background: rgba(0, 0, 0, 0.1);
                        border-radius: 2px;
                    }

                    .operation_btn {
                        height: 20px;
                        margin-right: 7px;
                    }
                }

            }
        }

        .tips {
            margin-bottom: 15px;
            font-size: 12px;
            color: rgb(151, 151, 151);
        }

        .serchBar {
            padding-bottom: 18px;

            .el-form {
                .el-form-item {
                    padding-right: 50px;
                }
            }
        }
    }

    .table {
        flex: 1;

        .btn {
            display: flex;
            justify-content: flex-end;
            align-items: center;
            height: 40px;
            padding-right: 25px;
            color: rgb(112, 105, 95);
            font-size: 14px;

            .btn_item {
                display: flex;
                align-items: center;
                margin-left: 20px;
                cursor: pointer;
                height: 28px;
                line-height: 28px;
                padding: 0 10px 0 8px;

                &:hover {
                    background: rgba(0, 0, 0, 0.1);
                    border-radius: 2px;
                }

                .btn_icon {
                    width: 18px;
                    margin-right: 6px;
                }
            }
        }

        .tableBg {
            height: calc(100% - 40px);
            background-color: #fff;
            border-radius: 8px;

            .btn_ative {
                width: 35px;
                height: 35px;
                line-height: 35px;
                cursor: pointer;
                display: inline-block;
                margin-right: 10px;
                text-align: center;
                margin-top: 12.5px;
                padding-top: 5px;
                vertical-align: sub;
                &:last-child {
                    margin-right: 0;
                }

                &:hover {
                    background: rgba(0, 0, 0, 0.1);
                    border-radius: 2px;
                }

                .operation_btn {
                    height: 20px;

                }
            }
        }
    }
}
</style>
